<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class pren{
            // 这里静态的只能类调
            static name='胡歌'
            static setfu=function(){
                console.log('彭于晏');
            }
            // 相当于构造方法Java里面
            constructor(names,ages){
                 this.names=names
                 this.ages=ages
            }
        }
        let p=new pren('彭于晏',21)
        console.log(p);//'彭于晏',21
        console.log(p.names);//彭于晏
        // new出来的对象调不了静态
        console.log(p.name);//undefined
        console.log(pren.name);//胡歌
    </script>
</body>
</html>